package com.hongye.proprietary.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.proprietary.entity.CompanyHomeEntity;
import com.hongye.proprietary.service.CompanyHomeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 公司表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 11:16:47
 */
@RestController
@RequestMapping("proprietary/companyhome")
public class CompanyHomeController {
    @Autowired
    private CompanyHomeService companyHomeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = companyHomeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{companyId}")
    public R info(@PathVariable("companyId") Integer companyId){
		CompanyHomeEntity companyHome = companyHomeService.getById(companyId);

        return R.ok().put("companyHome", companyHome);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CompanyHomeEntity companyHome){
		companyHomeService.save(companyHome);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CompanyHomeEntity companyHome){
		companyHomeService.updateById(companyHome);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] companyIds){
		companyHomeService.removeByIds(Arrays.asList(companyIds));

        return R.ok();
    }

}
